
uniform sampler2D		bumpMap;
uniform sampler2D		diffuseMap;
uniform sampler2D		lightProjectionMap;
uniform sampler2D		lightFalloffMap;

uniform vec3		diffuseColor;

varying vec2		bumpTexCoord;
varying vec2		diffuseTexCoord;
varying vec4		lightTexCoord;
varying vec4		vertexColor;


void main (void){

	const vec3	ambientDir = vec3(1.0, -1.0, 1.0);
	vec3		normalVec;
	vec3		diffuse, intensity;

	// Load the normal vector from the bump map
	normalVec = texture2D(bumpMap, bumpTexCoord).rgb * 2.0 - 1.0;
	normalVec = normalize(normalVec);

	// Modulate the diffuse map by the diffuse color
	diffuse = texture2D(diffuseMap, diffuseTexCoord).rgb * diffuseColor;

	// Compute ambient light contribution
	intensity = vec3(dot(ambientDir, normalVec));

	// Modulate by the light projection and falloff
	intensity *= texture2DProj(lightProjectionMap, lightTexCoord.stq).rgb;
	intensity *= texture2D(lightFalloffMap, vec2(lightTexCoord.p, 0.5)).rgb;

	// Apply light attenuation and modulate by the vertex color
	gl_FragColor = vec4(diffuse * intensity, 1.0) * vertexColor;
}
